package entities;

import java.io.Serializable;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;



/**
 * @author Idan
 *	This class is used to hold order data.
 */
public class ProductionOrder implements Serializable
{
	
	private static final long serialVersionUID = -606400860237275257L;
	private int orderID;
	private String type;
	private float diopter;
	private Timestamp orderDate;
	private int quantity;
	private int statusID;
	
	private Timestamp engraveDate;
	private Timestamp qcDate;
	private Timestamp polishDate;
	private String employee;
	private String employeeID;
	private int sideA=0;
	private int reportSideA=0;
	private int sideB=0;
	private int reportSideB=0;
	private String line;
	private int shift;
	private String engraveRemarks;
	
	private float failsPercentage=0;
	private String productFamily;
	private String fails;
	private int commentid1=0;
	private int commentid2=0;
	
	private int engraveID;
	private String rawMaterial;
	
	private String dateAsMonthYear;
	
	public void Productionorder()
	{
		// Create new instance
	}
	
	public void setOrderID(int orderID)
	{
		this.orderID = orderID;
	}

	public void setType(String type)
	{
		this.type = type;
	}

	public void setDiopter(float diopter)
	{
		this.diopter = diopter;
	}

	public void setOrderDate(Timestamp orderDate)
	{
		this.orderDate = orderDate;
	}

	public void setQuantity(int quantity)
	{
		this.quantity = quantity;
	}

	public void setStatusID(int statusID)
	{
		this.statusID = statusID;
	}
	
	public int getOrderID()
	{
		return this.orderID;
	}
	
	public String getType()
	{
		return this.type;
	}
	
	public float getDiopter()
	{
		return this.diopter;
	}
	
	public Timestamp getOrderDate() // I changed this to Timestamp instead of Date - If anything gets broken it should be changed back to Date
	{
		return this.orderDate;
	}
	
	public int getQuantity()
	{
		return this.quantity;
	}
	
	public int getStatusID()
	{
		return this.statusID;
	}
	
	public void setDateAsString(String date)
	{
		
		Date formattedDate;
		try 
		{
			formattedDate = new SimpleDateFormat("dd/MM/yyyy").parse(date);
			this.orderDate = new Timestamp(formattedDate.getTime());
		} catch (ParseException e)
		{
			// TODO Auto-generated catch block
			//e.printStackTrace();
		}
		
		
	
	}
	
	public String getDateAsString()
	{

		String formatted = new SimpleDateFormat("dd/MM/yyyy").format(orderDate);		
		return formatted;
	}
	
	
	public String getEngraveDateMonthAndYearAsString()
	{

		String formatted = new SimpleDateFormat("MM/yyyy").format(engraveDate);		
		return formatted;
	}
	
	public String getQcDateMonthAndYearAsString()
	{

		String formatted = new SimpleDateFormat("MM/yyyy").format(qcDate);		
		return formatted;
	}

	public Timestamp getEngraveDate() 
	{
		return engraveDate;
	}

	public void setQcDate (Timestamp qcDate)
	{
		this.qcDate = qcDate;
	}
	
	public Timestamp getQcDate() 
	{
		return qcDate;
	}

	public void setEngraveDate(Timestamp engraveDate)
	{
		this.engraveDate = engraveDate;
	}
	

	public void setEngraveDateAsString(String date)
	{
		
		Date formattedDate;
		try 
		{
			formattedDate = new SimpleDateFormat("dd/MM/yyyy").parse(date);
			this.engraveDate = new Timestamp(formattedDate.getTime());
			
		} catch (ParseException e)
		{
			// TODO Auto-generated catch block
			//e.printStackTrace();
		}	
	}
	
	public String getEngraveDateAsString()
	{

		String formatted = new SimpleDateFormat("dd/MM/yyyy").format(engraveDate);		
		return formatted;
	}

	
	public String getEmployee()
	{
		return employee;
	}

	public void setEmployee(String employee) {
		this.employee = employee;
		
	}

	public int getSideA()
	{
		return sideA;
	}

	public void setSideA(int sideA)
	{
		this.sideA = sideA;
	}

	public int getReportSideA()
	{
		return reportSideA;
	}

	public void setReportSideA(int reportSideA)
	{
		this.reportSideA = reportSideA;
	}

	public int getSideB()
	{
		return sideB;
	}

	public void setSideB(int sideB)
	{
		this.sideB = sideB;
	}

	public int getReportSideB()
	{
		return reportSideB;
	}

	public void setReportSideB(int reportSideB)
	{
		this.reportSideB = reportSideB;
	}

	public String getLine()
	{
		return line;
	}

	public void setLine(String line)
	{
		this.line = line;
	}

	public int getShift() 
	{
		return shift;
	}

	public void setShift(int shift)
	{
		this.shift = shift;
	}

	public String getEngraveRemarks() {
		return engraveRemarks;
	}

	public void setEngraveRemarks(String engraveRemarks)
	{
		this.engraveRemarks = engraveRemarks;
	}

	public int getCommentid1() {
		return commentid1;
	}

	public void setCommentid1(int commentid1)
	{
		this.commentid1 = commentid1;
	}

	public int getCommentid2() {
		return commentid2;
	}

	public void setCommentid2(int commentid2)
	{
		this.commentid2 = commentid2;
	}

	public String getEmployeeID() {
		return employeeID;
	}

	public void setEmployeeID(String employeeID) {
		this.employeeID = employeeID;
	}

	public int getEngraveID() {
		return engraveID;
	}

	public void setEngraveID(int engraveID) {
		this.engraveID = engraveID;
	}

	public Timestamp getPolishDate() 
	{
		return polishDate;
	}

	public void setPolishDate(Timestamp polishDate) 
	{
		this.polishDate = polishDate;
	}
	
	public void setPolishDateAsString(String date)
	{
		
		Date formattedDate;
		try 
		{
			formattedDate = new SimpleDateFormat("dd/MM/yyyy").parse(date);
			this.polishDate = new Timestamp(formattedDate.getTime());
		} catch (ParseException e)
		{
			// TODO Auto-generated catch block
			//e.printStackTrace();
		}
		
		
	
	}
	
	public String getPolishDateAsString()
	{

		String formatted = new SimpleDateFormat("dd/MM/yyyy").format(polishDate);		
		return formatted;
	}

	public String getProductFamily() {
		return productFamily;
	}

	public void setProductFamily(String productFamily) {
		this.productFamily = productFamily;
	}

	public String getFails() {
		return fails;
	}

	public void setFails(String fails) {
		this.fails = fails;
	}

	public float getFailsPercentage() {
		return failsPercentage;
	}

	public void setFailsPercentage(float failsPercentage) {
		this.failsPercentage = failsPercentage;
	}

	public String getDateAsMonthYear() {
		return dateAsMonthYear;
	}

	public void setDateAsMonthYear(String dateAsMonthYear) {
		this.dateAsMonthYear = dateAsMonthYear;
	}

	public String getRawMaterial() {
		return rawMaterial;
	}

	public void setRawMaterial(String rawMaterial) {
		this.rawMaterial = rawMaterial;
	}



	
}
